enum WinNameRecord {
  /**
     * 添加页面
     */
  ORDER_CREATE,
  /**
     * 详情页面
     */
  ORDER_DETAIL,
  /**
     * 编辑页面
     */
  ORDER_UPDATE,
  /**
     * 产品详情页
     */
  ORDER_PRODUCT_DETAIL,
  /**
   * 发货新建页
   */
  SHIPPING_CREATE,
  /**
   * 发货详情页
   */
  SHIPPING_DETAIL,
  /**
   * 发货编辑页
   */
  SHIPPING_UPDATE,
}
class Win {
  open(url: string, winName: WinNameRecord, ...attachToName: string[]) {
    const name = this.name(winName, attachToName && attachToName.length > 0 ? attachToName.join('-') : "");
    window.open(url, name);
    return this;
  }
  close(delayMs?: number) {
    delayMs = delayMs || 0;
    setTimeout(() => {
      window.close();
    }, delayMs);
  }
  reload() {
    window.location.reload();
  }
  private name(prefix: WinNameRecord, attach: string) {
    return `${prefix}${attach ? "-" + attach : ""}`;
  }
}

const WinUtil = new Win();

export { WinNameRecord }
export default WinUtil;
